import request from '@/utils/request'

export interface ServiceDTO {
  serviceId?: string
  serviceNo: string
  serviceName: string
  customerId: string
  contactId?: string
  contractId?: string
  serviceType: 'SUPPORT' | 'REPAIR' | 'TRAINING' | 'OTHER'
  priority?: 'LOW' | 'NORMAL' | 'HIGH' | 'URGENT'
  ownerUserId?: string
  ownerDeptId?: string
  requestDate: string
  expectedDate?: string
  actualDate?: string
  description?: string
  solution?: string
  satisfactionScore?: number
  satisfactionComment?: string
  status?: 'OPEN' | 'IN_PROGRESS' | 'RESOLVED' | 'CLOSED'
  procInsId?: string
  remark?: string
}

// 客户服务管理API
export function pageService(params: {
  pageNum: number
  pageSize: number
  serviceNo?: string
  serviceName?: string
  customerId?: string
  contractId?: string
  serviceType?: string
  priority?: string
  ownerUserId?: string
  status?: string
  startTime?: string
  endTime?: string
}) {
  return request({ url: '/crm/service/page', method: 'get', params })
}

export function getService(id: string) {
  return request({ url: `/crm/service/${id}`, method: 'get' })
}

export function createService(data: ServiceDTO) {
  return request({ url: '/crm/service', method: 'post', data })
}

export function updateService(id: string, data: ServiceDTO) {
  return request({ url: `/crm/service/${String(id)}`, method: 'put', data })
}

export function deleteService(id: string) {
  return request({ url: `/crm/service/${String(id)}`, method: 'delete' })
}

export function deleteServiceBatch(ids: string[]) {
  return request({ url: '/crm/service/batch-delete', method: 'post', data: ids })
}


